﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project2
{
    internal class Overload重载
    {
        private static void MainOverload重载(string[] args)
        {
            int x = 2;
            int y = 1;
            Calculator calculator = new Calculator();

            int z = calculator.Add(x, out y);
            Console.WriteLine(z);
            Console.WriteLine(y);
        }
    }

    internal class Calculator
    {
        public int Add(int x, int y)
        {
            return x + y;
        }

        //public double Add(int x, int y)
        //{
        //    return x + y;
        //}
        //返回值类型不构成重载

        public double Add(double x, double y)
        {
            return x + y;
        }

        public int Add(int x, int y, int z)
        {
            return x + y + z;
        }

        //类型形参，泛型
        public int Add<T>(int x, int y)
        {
            T t;
            return x + y;
        }

        /// <summary>
        /// 参数的种类，ref，out，in
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public int Add(ref int x, int y)
        {
            return x + y;
        }

        public int Add(int x, out int y)
        {
            y = 123;
            return x + y;
        }
    }
}